package csu.web.mypetstore.web.servlet;

import csu.web.mypetstore.domain.Logger;
import csu.web.mypetstore.service.LoggerService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

public class LoggerFormServlet extends HttpServlet {
    private static final String LOGGER_FORM = "/WEB-INF/jsp/account/logger.jsp";

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        LoggerService loggerService = new LoggerService();
        HttpSession session = req.getSession();
        List<Logger> loggerList = loggerService.getLoggerList();
        session.setAttribute("loggerList",loggerList);
        req.getRequestDispatcher(LOGGER_FORM).forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
